#include <iostream>
#include <vector>
#include <boost/bind.hpp>
#include <boost/assert.hpp>
#include <algorithm>
#include <boost/lambda/lambda.hpp>
#include <boost/progress.hpp>
using namespace boost;
using namespace std;

struct AA {
    AA():value(0) {}
    int value;
    string str;
};

void find_1(vector<AA> &vec);
void find_2(vector<AA> &vec);

int main()
{
    cout << "--- Start ---" << endl;
    vector<AA> vec(1000000);
    vec[999999].value = 22;
    vec[999999].str = "hello.";

    progress_timer t;
    int count = 10000;
    while(count--) {
        find_1(vec); 
    }
    cout << t.elapsed() << endl;
    cout << "--- End ---" << endl;
    return 0;
}

void find_1(vector<AA> &vec)
{
    vector<AA>::iterator iter = vec.begin(); 
    while (iter != vec.end() && iter->value != 22) {
        ++ iter;
    }
    assert(iter != vec.end());
}

void find_2(vector<AA> &vec)
{
    vector<AA>::iterator iter = 
        find_if(vec.begin(), vec.end(),
             bind(&AA::value, _1) == 22);
    assert(iter != vec.end());
}
